package com.linsen.gateway.handler;

import cn.dev33.satoken.stp.StpInterface;
import cn.dev33.satoken.stp.StpUtil;
import com.linsen.core.redis.util.RedisSecurityUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author zhaoyong
 * @date 2023/3/15
 */
@Primary
@Component
@RequiredArgsConstructor
public class SaTokenHandler implements StpInterface {
    private final RedisSecurityUtil redisSecurityUtil;

    @Override
    public List<String> getPermissionList(Object o, String s) {
        return this.redisSecurityUtil.getPermissionList(StpUtil.getTokenValue());
    }

    @Override
    public List<String> getRoleList(Object o, String s) {
        return this.redisSecurityUtil.getRoleList(StpUtil.getTokenValue());
    }
}
